1. Technical Field
This disclosure generally relates to computer systems, and more specifically relates how a compiler generates code in computer systems.
2. Background Art
Computer systems have evolved into extremely sophisticated devices, and computer systems may be found in many different settings. Dramatic advances in both hardware and software (e.g., computer programs) have drastically improved the performance of computer systems. Modern software has become very complex when compared to early computer programs. Many modern computer programs have tens or hundreds of thousands of instructions. The execution time (and hence, performance) of a computer program is very closely related to the number and complexity of instructions that are executed as the computer program runs. Thus, as the size and complexity of computer programs increase, the execution time of the computer program increases as well.
Unlike early computer programs, modern computer programs are typically written in a high-level language that is easy to understand by a human programmer. Special software tools known as compilers take the human-readable form of a computer program, known as “source code”, and convert it into “machine code” or “object code” instructions that may be executed by a computer system. Because a compiler generates the stream of machine code instructions that are eventually executed on a computer system, the manner in which the compiler converts the source code to object code affects the execution time of the computer program.
Memory aliasing can occur when two pointers in a computer program refer to the same memory address at some point in time during execution. Compilers that use pointers to dynamically allocated memory often cannot rule out aliasing of memory addresses derived from different pointers. Register promotion is a very useful compiler optimization that improves performance, for example in inner loops, by using registers instead of memory addresses to store intermediate values. However, if values are stored and loaded using pointers that have an address range cannot be determined by static compiler analysis, compilers have to generate corresponding load and store instructions without doing optimization such as register promotion due to the risk of memory aliasing occurring. As a result, when known compilers cannot rule out memory aliasing for a particular region of code, register promotion for that region of code is not done by the compiler. The result is a computer program generated by the compiler that is not as optimized as it could otherwise be due to the risk of memory aliasing.